package com.amrit.collection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.TreeSet;


public class ReviseSet {

	/**
	 * @param args
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void main(String[] args) {
		ArrayList al = new ArrayList();
		al.add(14);
		al.add(16);
		al.add(18);
		al.add(20);
		al.add(12);
		al.add(10);
		al.add(18);
		al.add(20);
		System.out.println(al.size());
		TreeSet ts = new TreeSet<>(al);
		ts.add(2);
		//System.out.println(ts.toString() + " and size is: " + ts.size());
		Iterator it = ts.iterator();
		while(it.hasNext()){
			if(it.next() instanceof Integer){
				System.out.println(it.next());
			}else if (it.next() instanceof String){
				System.out.println(it.next());
			}
		}

		/*while (!ts.isEmpty()){
			System.out.println(ts.iterator().next());
			ts.iterator().remove();
		}
		 */	}
}